<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/axios.min.js"></script>
    <script src="/util.js"></script>
    <script>
        function add(){
            //清空错误信息
            $("nameDiv").innerHTML = "";
            $("birthdayDiv").innerHTML = "";
            $("moneyDiv").innerHTML = "";

            axios.get("/user/add",{
                params:{
                    name:$("name").value,
                    birthday:$("birthday").value,
                    money:$("money").value
                }
            }).then(e =>{
                var info = e.data;
                if(info == "ok"){
                    location.href = "/index.html";
                }
                else{
                    for(var i=0;i<info.length;i++){
                        $(info[i].field+"Div").innerHTML = info[i].defaultMessage;
                    }
                }
            });
        }
    </script>
</head>
<body>
    用户名：<input type="text" id="name"><br>
    <div id="nameDiv"></div>
    生日：<input type="text" id="birthday"><br>
    <div id="birthdayDiv"></div>
    工资：<input type="text" id="money"><br>
    <div id="moneyDiv"></div>
    <input type="button" value="添加" onclick="add()">
</body>
</html>